﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.Commont.Domains.AnimalsDomainFiles;
using Traceability.Commont.DTOs;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.DTOs.SectionDto;
using Traceability.Commont.DTOs.WhiteStripWeighingHtmlGroup;
using U.Enterprise.Api.Applications.AdmissionRegistrationFile;
using U.Enterprise.Api.Applications.GETSection;
using U.Enterprise.Api.Applications.PartitionWarehousings;
using U.Enterprise.Api.Applications.Scalesetting;
using U.Enterprise.Api.Applications.WhitestripWeighing;

namespace U.Enterprise.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SectionController : ControllerBase
    {


        private readonly IMediator _imediator;

        public SectionController(IMediator imediator
            )
        {
            _imediator = imediator;
        }


        /// <summary>
        /// 部门添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> SectionCreate(SectionCreateCommond request, CancellationToken cancellationToken)
        {

            var query = await _imediator.Send(request);

            return query;

        }
        /// <summary>
        /// 扣减项加载
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<DeductionDTO>> liveDedu(DeductionDTOListCommand info)
        {
            try
            {
                var res = await _imediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 部门显示页面
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<SectiongetDto> SectionHtml(SectionHtmlCommond request, CancellationToken cancellationToken)
        {
            var list = await _imediator.Send(request);

            return list;

        }

        /// <summary>
        /// 新增磅秤类型
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> ScaleTypeAdd(ScaleTypeCreateCommand cmd)
        {
            return await _imediator.Send(cmd);
        }
        /// <summary>
        /// 磅秤
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<ScaleType>> ScaleTypeList(ScaleTypeListCommand cmd)
        {
            try
            {
                var res = await _imediator.Send(cmd);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 磅秤设置新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<Resqults> ScaleSettingCreate(ScaleSettingCreateCommond request, CancellationToken cancellationToken)
        {
            var list = await _imediator.Send(request);

            return list;

        }


        /// <summary>
        /// 磅秤设置显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<PageDTO<Scale>> ScaleDisplayHtml(ScaleDisplayHtmlCommond request, CancellationToken cancellationToken)
        {
            var list = await _imediator.Send(request);


            return list; 

        }


        /// <summary>
        /// 待宰圈添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> WaitingCircleCteate(WaitingCircleCteateCommond request, CancellationToken cancellationToken)
        {

            var list = await _imediator.Send(request);

            return list;


        }



        /// <summary>
        /// 代宰圈显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageDTO<SlaughterCircleSelectDTO>> WaitingCircleHtml(WaitingCircleHtmlCommond request, CancellationToken cancellationToken)
        {

            var list = await _imediator.Send(request);

            return list;


        }

        /// <summary>
        /// 扣减项新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> DeductionsCreate(DeductionsCreateCommond request, CancellationToken cancellationToken)
        {


            var res = await _imediator.Send(request);
            return res;



        }
        /// <summary>
        /// 扣减项显示页面
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageDTO<Deductions>> DeductionsHtml(DeductionsHtmlCommond request, CancellationToken cancellationToken)
        {

            var res = await _imediator.Send(request);


            return res;


        }
        /// <summary>
        /// 分割领用新增
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> PartitionAdd(PartitionCreateCommand cmd)
        {
            return await _imediator.Send(cmd);
        }
        /// <summary>
        /// 分割领用列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> PartitionSearch(PartitionSearchCommand cmd)
        {
            return await _imediator.Send(cmd);
        }
        /// <summary>
        /// 分割领用动态商品
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<Shopping>> ShopSearch(ShopListCommand cmd)
        {
            return await _imediator.Send(cmd);
        }
        /// <summary>
        /// 分割领用分组显示
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<SpliteGroupDTO>> groupSplit(SearchGroupCommand info)
        {
            try
            {
                var res = await _imediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }

    }
}
